Skip to content

feat(my-space): update company info banner to match new design#3168

Merged
LucasCharrier merged 4 commits intoalphafrom
feat/figma-8449-86666
Apr 8, 2026
Merged

feat(my-space): update company info banner to match new design#3168
LucasCharrier merged 4 commits intoalphafrom
feat/figma-8449-86666

Conversation

@LucasCharrier
Copy link
Copy Markdown
Contributor

No description provided.

@LucasCharrier LucasCharrier requested a review from a team as a code owner April 8, 2026 08:56
@revu-bot revu-bot Bot requested a review from revu-bot April 8, 2026 08:56
@LucasCharrier LucasCharrier linked an issue Apr 8, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@revu-bot revu-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR updates the CompanyInfoBanner component to match a new design: flatter layout using flexbox rows, a new formatAddress utility for title-casing INSEE/Weez uppercase addresses, and minor copy/style tweaks. The overall approach is clean and well-tested.

File Lines Severity Issue
formatAddress.ts 20–24 CRITICAL offset parameter is the byte offset of the match, not the word index — first-word detection is broken for addresses starting with digits or punctuation
formatAddress.ts 19–24 IMPORTANT No JSDoc on exported public function (violates coding guidelines)
formatAddress.ts 1–24 IMPORTANT Missing dedicated unit tests for formatAddress edge cases

One critical logic bug in formatAddress needs fixing before merge; the other two are important maintainability gaps.

Comment on lines +19 to +26
export function formatAddress(address: string): string {
return address
.toLocaleLowerCase("fr-FR")
.replace(/\p{L}+/gu, (word, offset: number) => {
if (offset > 0 && LOWERCASE_WORDS.has(word)) return word;
return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1);
});
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CRITICAL] offset is the character offset of the match, not the word index — first-word capitalisation is broken

Why it matters:

  • The offset parameter passed by String.prototype.replace is the character position of the match within the string, not a word counter.
  • offset > 0 is therefore false only when the very first character of the entire string is a letter. Any address that starts with a digit or whitespace (e.g. "12 RUE DE PARIS") will have offset > 0 for every word, including "rue", which is in LOWERCASE_WORDS — so "rue" will be left lowercase instead of being capitalised.
  • Concretely, formatAddress("12 RUE DE PARIS") currently returns "12 rue de paris" instead of "12 Rue de Paris".

Proposed fix: track whether a capitalised word has already been emitted using a closure variable.

Suggested change
export function formatAddress(address: string): string {
return address
.toLocaleLowerCase("fr-FR")
.replace(/\p{L}+/gu, (word, offset: number) => {
if (offset > 0 && LOWERCASE_WORDS.has(word)) return word;
return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1);
});
}
export function formatAddress(address: string): string {
let firstWordCapitalised = false;
return address
.toLocaleLowerCase("fr-FR")
.replace(/\p{L}+/gu, (word) => {
if (firstWordCapitalised && LOWERCASE_WORDS.has(word)) return word;
firstWordCapitalised = true;
return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1);
});
}

This correctly capitalises the first alphabetic word regardless of any leading digits/punctuation, and keeps connector words lowercase thereafter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive: rue is not in LOWERCASE_WORDS (only connectors like de, du, la, le, les, et, en, aux, sur, sous, d, l). The existing test "12 RUE DE PARIS, 75001 PARIS""12 Rue de Paris, 75001 Paris" passes. The offset > 0 guard exists to capitalize a connector when it's the very first word (e.g. "LE MANS""Le Mans").

"l",
]);

export function formatAddress(address: string): string {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IMPORTANT] Missing JSDoc on exported public function

Why it matters:

  • The coding guidelines require public functions to have concise docstrings explaining purpose and return values.
  • formatAddress is exported and non-trivial (locale-aware title-casing with a connector-word allowlist), so future readers benefit from a brief description.

Proposed addition:

Suggested change
export function formatAddress(address: string): string {
/**
* Converts a fully-uppercased INSEE/Weez address to title case.
* Short French connector words (de, du, la, le, ) are kept lowercase
* unless they are the first word of the address.
*
* @param address - The raw uppercase address string.
* @returns The address formatted in title case.
*/
export function formatAddress(address: string): string {

@tokenbureau
Copy link
Copy Markdown

tokenbureau Bot commented Apr 8, 2026

@LucasCharrier LucasCharrier merged commit f0b5916 into alpha Apr 8, 2026
18 checks passed
@LucasCharrier LucasCharrier deleted the feat/figma-8449-86666 branch April 8, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refacto du header de la déclaration

3 participants